@layout("/common/_curd/_container.html"){

<script type="text/javascript">
	var ctx = "${basePath}";
	var grid_selector = "#grid-table";
	var pager_selector = "#grid-pager";
	
	$(function(){
		initGrid();
		initMenuBtn("btns", "${code}");
	});
	
	function initGrid(){
		var grid_url = ctx + "/${code}/list";
		var _colnames = ["主键", 
						"学校",
						"供应商", 
						"供应商编号",
						"地址",
						"联系人",
						"联系方式"
		];
		var _colmodel = [{name:"id", index:"id",hidden:true, width:100},
						{name:"sname",hidden:true, index:"sname", width:100},
						{name:"name", index:"name", width:100},
						{name:"code", index:"code", width:100},
						{name:"address", index:"address", width:100},
						{name:"concat", index:"concat", width:100},
						{name:"tel", index:"tel", width:100}
		];
		
		jQuery(grid_selector).jqGrid({
			url : grid_url,
		    shrinkToFit : true,
			colNames : _colnames,
			colModel : _colmodel, 
			jsonReader : {id :"id"},
			pager : pager_selector,
			postData : {sort : "id",
				where:"{ustatus:1}",
				order : "desc"}
		});
	}
</script>


	<!-- 配置 grid -->
	<div class="row">
		<div class="col-xs-12 tb-grid">
			<!-- 配置 查询 -->
			@ var _col=[
			@		{name:"学校", index:"sname", type:"text"},
			@		{name:"供应商", index:"name", type:"text"},
			@		{name:"地址", index:"address", type:"text"},
			@		{name:"编号", index:"code", type:"text"},
			@		{name:"联系人", index:"concat", type:"text"},
			@		{name:"联系方式", index:"tel", type:"text"}
			@];
			@ include("/common/_function/_search.html",{"col":_col}){}
			<!-- 按钮 -->
			<a href="#" id="choose" class="btn btn-btn btn-success btn-xs" onclick="getSelecteds()">确认选择</a>
			<!--<div class="welljq well-sm" id="btns"></div>-->
			<!-- grid -->
			<table id="grid-table"></table>
			<!-- 分页-->
			<div id="grid-pager"></div>
		</div>
	</div>
	
	<!-- 引入所需的js -->
	@include("/common/_listscript.html"){}
	<script>
		function getSelecteds(){
			var ids = $("#grid-table").jqGrid("getGridParam", "selarrrow");
			var name = ""
			var newname = ""
			$.each(ids,function (index, id){
				var row = $("#grid-table").jqGrid('getRowData', id);
				name =  name +"  "+row.name;
			})
			if(parent.document.getElementById("supplierName")){
				parent.document.getElementById("supplierName").value=name;
			}
			if(parent.document.getElementById("supplierId")){
				parent.document.getElementById("supplierId").value=ids;
			}
			if(parent.document.getElementById("_sname")){
				parent.document.getElementById("_sname").value=name;
			}
			if(parent.document.getElementById("_s_id")){
				parent.document.getElementById("_s_id").value=ids;
			}


			var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
			parent.layer.close(index); //再执行关闭
		}
	</script>
@}	